package com.info.zhiduoduo.admin.service;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.info.zhiduoduo.admin.model.formbean.maker.MakerStudioFormBean;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import com.info.zhiduoduo.core.service.common.BaseService;
import com.info.zhiduoduo.repository.dto.maker.MakerStudioDto;
import com.info.zhiduoduo.repository.mapper.maker.MakerStudioMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class MakerStudioService extends BaseService {
    @Resource
    MakerStudioMapper makerStudioMapper;

    public SmartResult findMakerStudio(BaseSimpleFormBean<MakerStudioFormBean> formBean) {
        if (formBean == null || formBean.getReqdata() == null) {
            return errorParamSmartResult();
        }
        Page<Object> page = PageHelper.startPage(formBean.getPage(), formBean.getRows());
        List<MakerStudioDto> makerStudio = makerStudioMapper.findMakerStudio(formBean.getReqdata().getName());
        return smartResult(makerStudio, page.getTotal(), page.getPages(), page.getPageNum());
    }


}
